<template name="fileManagement">
    {{> pageHeading title=getPageHeading }}

    {{#if isConnected}}
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>{{_ "file_management"}}</h5>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "bucket_name"}}</label>
                                    <div class="col-lg-11">
                                        <input id="txtBucketName" type="text" class="form-control"
                                               value="fs">
                                    </div>
                                </div>

                                {{> selector}}
                                {{>uploadFile}}

                                <div class="form-group">
                                    <label class="col-lg-1 control-label">{{_ "limit"}}</label>
                                    <div class="col-lg-11">
                                        <input id="txtFileFetchLimit" value="100"
                                               data-required="true"
                                               min="1"
                                               max="200"
                                               type="number"
                                               placeholder="{{_ "limit"}}"
                                               class="form-control">
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>

                                <div class="form-group">
                                    <div class="col-lg-12">
                                        <div class="pull-right">
                                            <button id="btnDeleteFiles"
                                                    style="margin-right: 10px;"
                                                    class="btn btn-danger btn-outline ladda-button "
                                                    type="button"
                                                    data-style="contract">
                                                <i class="fa fa-ban"></i>
                                                {{_ "delete"}}
                                            </button>

                                            <button id="btnReloadFiles"
                                                    class="btn btn-outline btn-primary ladda-button "
                                                    type="button"
                                                    data-style="contract">
                                                <i class="fa fa-refresh"></i>
                                                {{_ "refresh"}}
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>{{_ "files"}}</h5>
                        </div>
                        <div class="ibox-content">
                            <div class="dataTables_wrapper form-inline dt-bootstrap">
                                <table id="tblFiles"
                                       class="table table-striped table-bordered table-hover dataTables-example dataTable">
                                    <thead>
                                    <tr>
                                        <th>Id</th>
                                        <th>{{_ "file_name"}}</th>
                                        <th>{{_ "chunk_size"}}</th>
                                        <th>{{_ "upload_date"}}</th>
                                        <th>{{_ "length"}}</th>
                                        <th>{{_ "full_file_info"}}</th>
                                        <th>{{_ "download"}}</th>
                                        <th>{{_ "delete"}}</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <!-- MODAL show meta data-->
        <div class="modal inmodal" id="metaDataModal" tabindex="-1" role="dialog" aria-hidden="true"
             style="display: none;">
            <div class="modal-dialog">
                <div class="modal-content animated bounceInRight">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span
                                aria-hidden="true">×</span><span
                                class="sr-only">{{_ "close"}}</span></button>
                        <h4 class="modal-title">{{_ "full_file_info"}}</h4>
                        <small class="font-bold">{{_ "additional_file_info_desc"}}
                        </small>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div id="jsonEditorOfMetadata" style="width: 100%;height:500px" class="col-lg-12">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <div class="pull-left">
                            <button id="btnClose"
                                    class="btn btn-block btn-outline btn-primary"
                                    type="button"
                                    data-dismiss="modal">
                                <strong>{{_ "close"}}</strong></button>
                        </div>
                        <button id="btnUpdateMetadata" title="Save" type="button"
                                class="btn btn-primary ladda-button" data-style="contract">{{_ "save"}}
                        </button>


                    </div>
                </div>
            </div>
        </div>

        {{> fileInfo}}
    {{/if}}
</template>